//
//  DiscoverViewController.swift
//  weibo
//
//  Created by guo3920591 on 16/4/15.
//  Copyright © 2016年 guo3920591. All rights reserved.
//

import UIKit

private let CZDiscoverCell = "CZDiscoverCell"
class DiscoverViewController: RootViewController {

    override func viewDidLoad() {
        
        
       let  searchView=SearchView.searchView()
        
        searchView.frame.size.width = UIScreen.mainScreen().bounds.width

      //设置刷新控价
        setupControl()
        
        super.viewDidLoad()
        
        tableView?.registerClass(UITableViewCell.self, forCellReuseIdentifier: CZDiscoverCell)
        
        guard let vis = vistorView else{
            
            navigationItem.titleView = searchView
            
            return
            
        }
        
         vis.setup("visitordiscover_image_message", titletext: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    override func loadData() {
        /// @param DISPATCH_TIME_NOW 现在
        /// @param Int64##Int64#>    时间差 纳秒 description#>
        //开始刷新
       refreshControl.beginRefreshing()
       
       dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(Double(NSEC_PER_SEC)*1.0)), dispatch_get_main_queue()) { () -> Void in
       
        
        self.countNum += 10
        
        //结束刷新
        
        self.refreshControl.endRefreshing()
     
        
        self.tableView?.reloadData()
        
        }
        
      
        
    }
    /// 私有属性
    private lazy var countNum = 0

}

// MARK: - 数据源方法
extension DiscoverViewController{
    
    
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return countNum
    }
    
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCellWithIdentifier(CZDiscoverCell, forIndexPath: indexPath)
        
        cell.textLabel?.text = "\(indexPath.row)"
        
        
        return cell
    }
    
    
}
